<?php
include_once("../../../common/module/checkA.php");
include_once("../../../../config.php");
include_once("../controller/detail-list.php");
include_once("module/select_category.php");

?>


<?


$detail=select_one_line_all_items($table_prefix."product","nid = '".$_REQUEST['nid']."'");

$salse_record=select_lines_all_items($table_prefix."order_detail","","product_nid = '".$_REQUEST['nid']."' ","");

$order_nid_list=transform_2darray_in_1darray_number_as_key($salse_record,"order_nid");
$order_nid_str=implode($order_nid_list,"','");
$order_list=select_lines_all_items($table_prefix."order_list","","nid  in ('".$order_nid_str."')","");


$order_list_client = transform_2darray_in_1darray_with_new_key($order_list,"nid","name");
$order_list_sn     = transform_2darray_in_1darray_with_new_key($order_list,"nid","order_sn");
$order_list_date   = transform_2darray_in_1darray_with_new_key($order_list,"nid","date");
$order_list_price  = transform_2darray_in_1darray_with_new_key($order_list,"nid","price");


?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

    <? include_once(ROOT_PATH_ . "/controller/common/module/head.php"); ?>

    <?php include 'module/head.php'; ?>
</head>

<body>

<div id="topbar">
    <?php include ROOT_PATH_ . '/controller/common/module/topbar.php'; ?>
</div>

<div id="container" class="<? echo $system_part ?>">

    <div id="maincontent">

        <div id="sidebar">
            <?php include ROOT_PATH_ . '/controller/common/module/sidebar.php'; ?>
        </div>




        <div id="content">
            <?php $page_title = '产品详情'; ?>
            <?php include ROOT_PATH_ . '/controlbase/module/mod-page-title.php'; ?>




            <div class="detail-box layui-form">

<div class="detail-boxes">
<div class="detail-boxing">

    <table class="layui-table">
        <colgroup>
            <col width="  ">
        </colgroup>
        <thead>
        <tr>
            <th>商品名字</th>
            <th>产品型号</th>
            <th>商品分类</th>
            <th>商品价格</th>
            <th>最低起订</th>
            <th>库存</th>
            <th>状态</th>
            <th>排序</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
            <tr >
                <td><? echo $detail['name']?></td>
                <td><? echo $detail['model']?></td>
                <td>
                    <?
                    if($category){
                        foreach($category as $val){

                            if($val['nid'] == $detail[$i]['cat_id']){
                                echo $val['name'];
                            }
                        }
                    }
                    ?>
                </td>
                <td><? echo $detail['price']?></td>
                <td><? echo $detail['zuidiqiding']?></td>
                <td><? echo $detail['storage']?></td>
                <td><? echo $detail['publish'] == 1 ? '显示' : '隐藏'?></td>
                <td><? echo $detail['status']?></td>
                <td><a href="detail-edit.php?nav-itemed=product&nid=<? echo $detail['nid']?>&now_extender=product"
                       target="_blank" class="layui-btn layui-btn-sm" >
                        <i class="layui-icon">&#xe642;</i>修改
                    </a>
                </td>
            </tr>
        </tbody>
    </table>





    <fieldset class="layui-elem-field layui-field-title">
        <legend>销售记录</legend>
    </fieldset>
    <table class="layui-table">
        <colgroup>
            <col width="80">
            <col width="200">
            <col >
            <col >
            <col >
            <col >
            <col >
            <col >
            <col >
            <col >
            <col >

        </colgroup>
        <thead>
        <tr>
            <th>序号</th>
            <th>客户</th>
            <th>订单编号</th>
            <th>订单日期</th>
            <th>订单数量</th>
            <th>订单金额</th>

            <th>产品数量</th>
            <th>产品单价</th>
            <th>产品总价</th>
            <th>汇率</th>
            <th>优惠活动</th>

        </tr>
        </thead>
        <tbody>



        <?php
        if (count($salse_record) == 0)
        {
            echo "<tr><td colspan='12'>暂无数据</td></tr>";
        }
        ?>




        <?php
        $i=1;
        foreach($salse_record as $k=>$val)
        {


            ?>

            <tr id="item<?echo $val['nid']?>" >
                <td><? echo $i++ ?></td>
                <td><?echo $order_list_client[$val['order_nid']]?></td>
                <td><? echo $val['order_nid'];?></td>
                <td><?echo $order_list_date[$val['order_nid']]?></td>
                <td>订单数量</td>
                <td><?echo $order_list_price[$val['order_nid']]?></td>

                <td><? echo $val['number'];?></td>
                <td><? echo $val['price'];?></td>
                <td><? echo $val['number']*$val['price'];?></td>

                <td><? echo $val['hiulv'];?></td>
                <td><? echo $val['youhuihuodong'];?></td>
            </tr>



            <?php

        }
        ?>


        </tbody>
    </table>








</ul>
</div>
</div>

<!--content端點01-->
</div>
<!--maincontent端點01-->
<br class="clearfloat"/>
</div>
<!--container端點01-->
</div>


<?php include ROOT_PATH_ . "/controller/common/module/footer.php"; ?> </body>
</html>
